﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace DeepEarth.Core.Utilities
{
    public static class LinqUtilities
    {
        public static IEnumerable<T> Concat<T>(this T value, IEnumerable<T> list)
        {
            return new[] { value }.Concat(list);
        }

        public static void Iter<T>(this IEnumerable<T> elements, Action<T> action)
        {
            foreach (var element in elements)
            {
                action(element);
            }
        }

        public static S Fold<T, S>(this IEnumerable<T> elements, Func<S, T, S> appliedFunction, S state)
        {
            return elements.Aggregate(state, appliedFunction);
        }
    }
}